package com.sys.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.sql.SQLException;

@Controller
public class ErrorController {
    @RequestMapping("test1")
    public String test1(){
        int num = 1/0;
        return "user";
    }

    @RequestMapping("test2")
    public String test2(){
        int[] a = {1,2,3};
        a[100] = 100;
        return "user";
    }

    /**
     * 局部异常处理，只对当前controller作用
     * 异常处理只能处理一次，不能重复配置相同异常类型
     * @return
     */
    /*@ExceptionHandler(RuntimeException.class)
    public ModelAndView errorHandler(RuntimeException e){
        return new ModelAndView("error","ex",e);
    }*/
}
